# Contributor: Umar Getagazov <umar@handlerug.me>
# Maintainer: Umar Getagazov <umar@handlerug.me>
pkgname=xone-src
_modname=${pkgname%-src}
pkgver=0.3_git20230517
pkgrel=0
_gitrev=bbf0dcc484c3f5611f4e375da43e0e0ef08f3d18
pkgdesc="Linux kernel driver for Xbox One and Xbox Series X|S accessories (sources)"
url="https://github.com/medusalix/xone"
arch="noarch"
license="GPL-2.0-or-later"
install="$pkgname.post-install"
provides="xone=$pkgver"
source="$_modname-$pkgver.tar.gz::https://github.com/medusalix/xone/archive/$_gitrev.tar.gz
	modules-load.conf"
options="!check"  # no tests
builddir="$srcdir/$_modname-$_gitrev"

package() {
	install -Dm644 "$srcdir"/modules-load.conf \
		"$pkgdir"/usr/lib/modules-load.d/xone-wired.conf
	install -Dm644 "$builddir"/install/modprobe.conf \
		"$pkgdir"/etc/modprobe.d/xone-blacklist.conf
	install -Dm755 "$builddir"/install/firmware.sh \
		"$pkgdir"/usr/bin/xone-get-firmware.sh
	install -Dm644 "$builddir"/Kbuild "$pkgdir"/usr/src/$_modname-$pkgver/Kbuild
	cp -r "$builddir"/bus "$builddir"/driver "$builddir"/transport \
		"$pkgdir"/usr/src/$_modname-$pkgver/

	cat >"$pkgdir"/usr/src/$_modname-$pkgver/AKMBUILD <<-EOF
	modname=$_modname
	modver=$pkgver-r$pkgrel
	built_modules="$_modname-wired.ko $_modname-dongle.ko $_modname-gip.ko "\\
		"$_modname-gip-gamepad.ko $_modname-gip-headset.ko $_modname-gip-chatpad.ko "\\
		"$_modname-gip-guitar.ko"
	EOF
}

sha512sums="
78cd605a5d56c8230e8800dd43f9f423da52d896625242669480211a4105bbce3364669b742f678b6b48ecd3bc42ad2982d46fe0c6e99ec8e05b69a47c5c88ab  xone-0.3_git20230517.tar.gz
838de6003c723dc3955986b9cde883cae6e29c90995798110f285b1b1b362116f9e3a065f541e8d5d132dc460d245b37ce7479e9189b63e5fe9adf0c5f37529f  modules-load.conf
"
